<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<div class="form-horizontal" role="form" >
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业名称:</label>
        <div class="col-md-9">
        	 <input id="name" value="${enterprise.name}"  type="text" placeholder="企业名称" class="form-control" name="name"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业法人:</label>
        <div class="col-md-9">
        	 <input id="legalPerson" value="${enterprise.legalPerson}"  type="text" placeholder="企业法人" class="form-control" name="legalPerson"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业性质:</label>
        <div class="col-md-9">
<%--         	 <input id="nature" value="${enterprise.nature}"  type="text" placeholder="企业性质:1-代理;2-货主" class="form-control" name="nature"/> --%>
	                 <label style="margin-top: 5px;"><input type="radio"  name="nature" id="nature_yes" value="1" checked=""> <i></i>代理</label>
	                 <label><input type="radio"  name="nature" id="nature_no" value="2" > <i></i>货主</label>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业等级:</label>
        <div class="col-md-9">
<%--         	 <input id="level" value="${enterprise.level}"  type="text" placeholder="企业等级(数据字典)" class="form-control" name="level"/> --%>
        	 <select placeholder="选择企业等级" class="form-control chosen-select" name="level" id="level">
        	 	<c:forEach items="${levelList}" var="vo">
					<option value="${vo.code }" <c:if test="${vo.code == enterprise.level}">selected="selected"</c:if>>${vo.name }</option>
				</c:forEach>
            </select>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">国家:</label>
        <div class="col-md-9">
        	 <input id="country" value="${enterprise.country}"  type="text" placeholder="国家" class="form-control" name="country"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">城市:</label>
        <div class="col-md-9">
        	 <input id="city" value="${enterprise.city}"  type="text" placeholder="城市" class="form-control" name="city"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业积分:</label>
        <div class="col-md-9">
        	 <input id="point" value="${enterprise.point}"  type="text" placeholder="企业积分" class="form-control" name="point"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业地址:</label>
        <div class="col-md-9">
        	 <input id="address" value="${enterprise.address}"  type="text" placeholder="企业地址" class="form-control" name="address"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业资质:</label>
        <div class="col-md-9">
<%--         	 <input id="aptitude" value="${enterprise.aptitude}"  type="text" placeholder="企业资质:1-IATA;2-WCA,3-其它" class="form-control" name="aptitude"/> --%>
        	 <select placeholder="选择企业资质" class="form-control chosen-select" name="aptitude" id="aptitude">
        	 	<c:forEach items="${aptitudeList}" var="vo">
					<option value="${vo.code }" <c:if test="${vo.code == enterprise.aptitude}">selected="selected"</c:if>>${vo.name }</option>
				</c:forEach>
            </select>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业电话:</label>
        <div class="col-md-9">
        	 <input id="tel" value="${enterprise.tel}"  type="text" placeholder="企业电话" class="form-control" name="tel"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业邮箱:</label>
        <div class="col-md-9">
        	 <input id="email" value="${enterprise.email}"  type="text" placeholder="企业邮箱" class="form-control" name="email"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业网址:</label>
        <div class="col-md-9">
        	 <input id="website" value="${enterprise.website}"  type="text" placeholder="企业网址" class="form-control" name="website"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">联络代表:</label>
        <div class="col-md-9">
        	 <input id="contractName" value="${enterprise.contractName}"  type="text" placeholder="联络代表" class="form-control" name="contractName"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">联系电话:</label>
        <div class="col-md-9">
        	 <input id="contractMobile" value="${enterprise.contractMobile}"  type="text" placeholder="联系电话" class="form-control" name="contractMobile"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">信用等级:</label>
        <div class="col-md-9">
        	 <input id="creditRating" value="${enterprise.creditRating}"  type="text" placeholder="信用等级" class="form-control" name="creditRating"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">银行卡号:</label>
        <div class="col-md-9">
        	 <input id="bankAccount" value="${enterprise.bankAccount}"  type="text" placeholder="银行卡号" class="form-control" name="bankAccount"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">开户银行:</label>
        <div class="col-md-9">
        	 <input id="openBank" value="${enterprise.openBank}"  type="text" placeholder="开户银行" class="form-control" name="openBank"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业认证文件:</label>
        <div class="col-md-9">
        	<div id="imageUploader">
			    <div id="imageFileList" class="uploader-list"></div>
			    <div id="imageFilePicker">选择图片</div>
			</div>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业合作协议:</label>
        <div class="col-md-9">
        	 <input id="agreement" value="${enterprise.agreement}"  type="text" placeholder="企业合作协议（图片）" class="form-control" name="agreement"/>
        </div>
    </div>
</div>

<script>
	 $(function(){
		 $("#level").chosen({ width: '100%' });
		 $("#aptitude").chosen({ width: '100%' });
		 
		var imageUploader = WebUploader.create({
		    auto: true,
		    swf:'${ctx}/static/css/plugins/webuploader/Uploader.swf',
		    server: 'http://webuploader.duapp.com/server/fileupload.php',
		    pick: '#imageFilePicker',
		    accept: {
		        title: 'Images',
		        extensions: 'gif,jpg,jpeg,bmp,png',
		        mimeTypes: 'image/*'
		    }
		});
		imageUploader.on( 'fileQueued', function( file ) {
			var $list=$("#imageFileList");
		    var $li = $(
		            '<div id="' + file.id + '" class="file-item thumbnail">' +
		                '<img>' +
		                '<div class="info">' + file.name + '</div>' +
		            '</div>'
		            ),
		        $img = $li.find('img');
		    $list.append( $li );
		    var thumbnailWidth=100,thumbnailHeight=100;
		    imageUploader.makeThumb( file, function( error, src ) {
		        if (error) {
		            $img.replaceWith('<span>不能预览</span>');
		            return;
		        }
		        $img.attr( 'src', src );
		    }, thumbnailWidth, thumbnailHeight );
		});
		imageUploader.on( 'uploadProgress', function( file, percentage ) {
		    var $li=$('#'+file.id),$percent = $li.find('.progress span');
		    if ( !$percent.length ) {
		        $percent = $('<p class="progress"><span></span></p>').appendTo($li).find('span');
		    }
		    $percent.css( 'width', percentage * 100 + '%' );
		});
		imageUploader.on( 'uploadSuccess', function( file ) {
		    $( '#'+file.id ).addClass('upload-state-done');
		});
		imageUploader.on( 'uploadError', function( file ) {
		    var $li = $( '#'+file.id ),$error = $li.find('div.error');
		    if (!$error.length) {
		        $error = $('<div class="error"></div>').appendTo( $li );
		    }
		    $error.text('上传失败');
		});
		imageUploader.on( 'uploadComplete', function( file ) {
		    $( '#'+file.id ).find('.progress').remove();
		    $("#imageFileList").append('<input name="imageUrl" type="hidden" value="'+file.src+'"/></td>');
		});
		 
	 })
</script>
